<style>
    body{
        color:#535353 !important
    }
    .balance-box{
        display: flex;
        align-items:center
    }
    .req{
        color: red;
    }
    .layui-input-block input{
        width: 50%;
    }
</style>
<div class="layuimini-container">
    <h2 style="margin-left: 30px;">资产管理</h2>
    <hr>
    <form id="app-form" class="layui-form layuimini-form">
        <input type="hidden" name="appid" value="{$rows.appid|default=''}">

        <div class="layui-form-item">
            <label class="layui-form-label">账户余额(元):</label>
            <div class="layui-input-block balance-box">
                <input type="text" placeholder="元" class="layui-input" value="{$rows.balance|default=''}" disabled style="width: 25%;">
                <button type="button" class="layui-btn layui-btn-primary recharge" style="margin-left: 10px;">在线充值</button>
                <button type="button" class="layui-btn layui-btn-primary details">查看明细</button>
            </div>
        </div>

        <!-- <div class="layui-form-item">
            <label class="layui-form-label">我的收入：</label>
            <div class="layui-input-block balance-box">
                <input type="text" placeholder="元" class="layui-input" value="{$rows.points_rate|default=''}" disabled style="width: 25%;">
                <button type="button" class="layui-btn layui-btn-primary" style="margin-left: 10px;">申请提现</button>
                <button type="button" class="layui-btn layui-btn-primary">查看明细</button>
            </div>
        </div> -->

        <div class="layui-form-item"> <label class="layui-form-label">开启余额提醒:</label>
            <div class="layui-input-block">
             <input type="checkbox" {if $rows.if_warning??''} checked="" {/if} name="if_warning" id="if_warning" lay-skin="switch" lay-filter="switchTest" lay-text="ON|OFF">
            </div>
        </div>

        <div class="layui-form-item warning_email" {if !($rows.if_warning??'')}  style="display: none;" {/if}>
            <label class="layui-form-label">余额提醒邮箱：</label>
            <div class="layui-input-block balance-box">
                <input type="text"  name="warning_email" id="warning_email" placeholder="请输入余额提醒邮箱" class="layui-input" value="{$rows.warning_email|default=''}" style="width: 25%;">
                <button type="button" class="layui-btn layui-btn-primary test-send" style="margin-left: 10px;">测试发送</button>
            </div>
        </div>

        <div class="layui-form-item warning_email" {if !($rows.if_warning??'')}  style="display: none;" {/if}>
            <label class="layui-form-label">开始提醒金额(元)</label>
            <div class="layui-input-block">
                <input type="text" name="warning_price" autocomplete="off" placeholder="请输入邮箱地址"
                    class="layui-input" value="{$rows.warning_price|default=''}">
            </div>
            
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label required">我的姓名：</label>
            <div class="layui-input-block">
                <input type="text" name="user_name" lay-verify="required" lay-reqtext="请输入我的姓名" autocomplete="off" placeholder="请输入我的姓名"
                    class="layui-input" value="{$rows.user_name|default=''}">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label required">我的公司：</label>
            <div class="layui-input-block">
                <input type="text" name="my_company" lay-verify="required" lay-reqtext="请输入我的公司" autocomplete="off" placeholder="请输入我的公司" class="layui-input"
                    value="{$rows.my_company|default=''}">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">联系方式：</label>
            <div class="layui-input-block">
                <input type="text" name="tel" autocomplete="off" placeholder="请输入联系方式" class="layui-input"
                    value="{$rows.tel|default=''}">
            </div>
        </div>

        <div class="hr-line"></div>
        <div class="layui-form-item text-center">
            <button class="layui-btn  layui-btn-normal layui-btn-sm" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">重置</button>
        </div>

    </form>
</div>
<script src="/static/common/js/jquery-1.10.1.min.js"></script>


<script>
    layui.use(['form', 'layer'], function() {
        form = layui.form,
        layer = layui.layer,

        addLinkUrl = "addData"
        sendLinkUrl = "testSend"

        //监听提交
        form.on('submit(formDemo)', function(data){
            $.ajax({
                url:addLinkUrl,
                data: $('#app-form').serialize(),
                type:'POST',
                success:function(result){
                    if (result.code == 1) {
                        layer.alert(result.msg, {icon: 1});
                    }else{
                        layer.alert(result.msg, {icon: 2});
                    }
                },
                error:function (res) {
                    layer.alert(result.msg, {icon: 2});
                }
            });

            return false;
        })

        //在线充值
       $('.recharge').click(function(){
        layer.alert('请联系商务公对公转账');
       })

        //测试发送  
       $('.test-send').click(function(){
            var warning_email=$('#warning_email').val();
            $.ajax({
                url:sendLinkUrl,
                data:{'warning_email':warning_email},
                type:'POST',
                success:function(result){
                    if (result.code == 1) {
                        layer.alert(result.msg, {icon: 1});
                    }else{
                        layer.alert(result.msg, {icon: 2});
                    }
                },
                error:function (res) {
                    layer.alert(result.msg, {icon: 2});
                }
            });

            return false;
       })

        //查看明细
       $('.details').click(function(){
            //获取当前页面的高度
            var height = $(document.body).height();
            //获取当前页面的宽度
            var width = $(document.body).width();
            layer.open({
                type: 2, // 类型2表示iframe层
                title: '资金明细', // 标题
                content: '/admin/mall.DealLog/index', // iframe的url
                //通过当前页面的高度宽度调节弹窗的大小
                area:[Number(width-50)+"px",Number(height*0.9)+"px"],
            });
       })
       
        // 显示邮箱
        form.on('switch(switchTest)', function(data){
            if(this.checked){
                $('.warning_email').show();
            }else{
                $('.warning_email').hide();
            }
        })

    })
</script>